package cn.iocoder.yudao.module.product.api.product;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.product.api.product.dto.ProductRespDTO;
import cn.iocoder.yudao.module.product.dal.dataobject.product.ProductDO;
import cn.iocoder.yudao.module.product.service.product.ProductService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class ProductApiImpl implements ProductApi {

    @Resource
    private ProductService productService;
    @Override
    public CommonResult<ProductRespDTO> getProduct(Long productId) {
        ProductDO product = productService.getProduct(productId);
        return CommonResult.success(BeanUtils.toBean(product, ProductRespDTO.class));
    }
}
